package com.reciver.common.config;

import org.springframework.web.servlet.config.annotation.*;
import org.springframework.context.annotation.Configuration;

/**
 * @author lgb
 * @date 2020年6月8日 下午8:02:47
 * Copyright (C) 深圳工勘科技
 * @说明: 全局跨域配置
 **/
@Configuration
@EnableWebMvc
public class GlobalWebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
         .allowedOrigins("*").allowCredentials(true).allowedHeaders("*")
         .allowedMethods("GET","POST","PUT","DELETE","OPTIONS").maxAge(3600);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	//注册receiveInterceptor拦截器
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("doc.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/**.html").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/resources/");
    }
    
}